<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <title>千锋健康</title>
    <meta content="千锋健康" name="description">
    <meta content="千锋健康" name="keywords">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link href="../plugins/elementui/index.css" rel="stylesheet">
    <link href="../plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <style type="text/css">
        .el-main {
            position: absolute;
            top: 70px;
            bottom: 0px;
            left: 200px;
            right: 10px;
            padding: 0;
        }
    </style>
</head>
<body class="hold-transition skin-purple sidebar-mini">
<div id="app">
    <el-container>
        <!--            头部窗口-->
        <el-header class="main-header" style="height:70px;">
            <!--                nav导航链接窗口 该窗口下一般存放各种链接-->
            <nav :class='' class="navbar navbar-static-top">
                <!--                    千锋logo 点击的跳转未设置-->
                <a class="logo" href="#" style="text-align:center">
                    <span class="logo-lg"><img src="../img/loginLogo.png"></span>
                </a>
                <!--                    logo标签结束-->
                <!--                    头部部分右侧-->
                <div class="right-menu">
                    <!--                        帮助未设置点击触发事件-->
                    <span class="help"><i aria-hidden="true" class="fa fa-exclamation-circle"></i>帮助</span>
                    <!--                        头像框点击会出现下拉选项-->
                    <el-dropdown class="avatar-container right-menu-item" trigger="click">
                        <div class="avatar-wrapper">
                            <!--                                头像 可以绑定vue做自定义 user表中有img列 也可以用这个固定模板-->
                            <img class="user-avatar" src="../img/user2-160x160.jpg">
                            <!--                                登录时查出的username赋进vue.data-->
                            {{username}}
                        </div>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item divided>
                                <!--                                    在此处设置修改密码的点击事件-->
                                <span @click="test" style="display:block;">修改密码</span>
                            </el-dropdown-item>
                            <el-dropdown-item divided>
                                <span style="display:block;" @click="logout">退出</span>
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </nav>
            <!--                导航链接窗口结束-->
        </el-header>
        <!--            头部窗口结束-->
        <!--            主体窗口-->
        <el-container>
            <!--                左侧布局-->
            <el-aside width="200px">
                <!--                    导航总框架-->
                <el-menu>
                    <!--                        一级导航-->
                    <el-submenu :index="menu.path" v-for="menu in menuList">
                        <template slot="title">
                            <i :class="menu.icon" class="fa"></i>
                            {{menu.title}}
                        </template>
                        <!--                            此处为什么同为template标签 下面的成为了二级导航-->
                        <template v-for="child in menu.children">
                            <el-menu-item :index="child.path">
                                <a :href="child.linkUrl" target="right">{{child.title}}</a>
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <!--                左侧布局结束-->
            <!--                右侧内容主体-->
            <el-container>
                <!--                    默认主体显示 需要更换-->
                <iframe class="el-main" frameborder="0" height="580px" name="right" src="show.html"
                        width="100%"></iframe>
            </el-container>
        </el-container>
    </el-container>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            username: "登录",
            menuList: [
                {
                    "path": "1",
                    "title": "工作台",
                    "icon": "fa-dashboard",
                    "children": []
                },
                {
                    "path": "2",
                    "title": "会员管理",
                    "icon": "fa-user-md",
                    "children": [
                        {
                            "path": "/2-1",
                            "title": "会员档案",
                            "linkUrl": "member.html",
                            "children": []
                        },
                        {
                            "path": "/2-2",
                            "title": "体检上传",
                            "children": []
                        },
                        {
                            "path": "/2-3",
                            "title": "会员统计",
                            "linkUrl": "all-item-list.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "3",
                    "title": "预约管理",
                    "icon": "fa-tty",
                    "children": [
                        {
                            "path": "/3-1",
                            "title": "预约列表",
                            "linkUrl": "order.html",
                            "children": []
                        },
                        {
                            "path": "/3-2",
                            "title": "预约设置",
                            "linkUrl": "ordersetting.html",
                            "children": []
                        },
                        {
                            "path": "/3-3",
                            "title": "套餐管理",
                            "linkUrl": "setmeal.html",
                            "children": []
                        },
                        {
                            "path": "/3-4",
                            "title": "检查组管理",
                            "linkUrl": "checkgroup.html",
                            "children": []
                        },
                        {
                            "path": "/3-5",
                            "title": "检查项管理",
                            "linkUrl": "checkitem.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "4",
                    "title": "健康评估",
                    "icon": "fa-stethoscope",
                    "children": [
                        {
                            "path": "/4-1",
                            "title": "中医体质辨识",
                            "linkUrl": "all-medical-list.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "5",     //菜单项所对应的路由路径
                    "title": "统计分析",     //菜单项名称
                    "icon": "fa-heartbeat",
                    "children": [//是否有子菜单，若没有，则为[]
                        {
                            "path": "/5-1",
                            "title": "会员数量统计",
                            "linkUrl": "report_member.html",
                            "children": []
                        },
                        {
                            "path": "/5-2",
                            "title": "预约套餐占比统计",
                            "linkUrl": "report_setmeal.html",
                            "children": []
                        },
                        {
                            "path": "/5-3",
                            "title": "运营数据统计",
                            "linkUrl": "report_business.html",
                            "children": []
                        }
                    ]
                }
            ]
        },
        methods: {
            test() {
                alert("test")
            },
            logout(){
                localStorage.setItem("security_token",null);
                location.href="../login.html";
            }
        },
        created() {
            let token = localStorage.getItem("security_token");
            if (!token){
                token = ""
            }
            //发送ajax请求，获取当前登录用户的用户名，用于页面展示
            axios({
                url:"http://localhost:8080/per/getLoginUsername",
                headers:{
                    token:token
                }
            }).then((result) => {
                    let code = result.data.code
                    if (result.data.code == 200) {
                        this.username = result.data.data;
                    } else if (result.data.code == 401 || result.data.code == 504 || result.data.code == 505) {
                        location.href="../login.html";
                    }
                }
            )
        }
    })

    $(function () {
        var wd = 200;
        $(".el-main").css('width', $('body').width() - wd + 'px');
    });
</script>
</html>
